try {

    // inject editor window styles
    var style = document.createElement('link');
    style.rel = 'stylesheet';
    style.type = 'text/css';
    style.href = chrome.extension.getURL('style.css');
    (document.head||document.documentElement).appendChild(style);

    // inject codemirror styles
    var style = document.createElement('link');
    style.rel = 'stylesheet';
    style.type = 'text/css';
    style.href = chrome.extension.getURL('lib/codemirror.css');
    (document.head||document.documentElement).appendChild(style);


    // inject editor window
	var tb = document.createElement('div');
    tb.className = "less-edit-container";
	document.body.appendChild(tb);

    var styleText = document.createElement('textarea');
    styleText.id = "less-edit-container-textarea";
    styleText.value = '/* Write your LESS code here */' +
        '\n\n';
    tb.appendChild(styleText);

    var editor = CodeMirror.fromTextArea(styleText, {
        indentUnit: 4,
        tabMode: "shift",
        matchBrackets: true,
        mode: "css",
        onKeyEvent: function(e , s){
            if (s.type == "keyup")
            {
                styleString = editor.getValue();

                // parse scss
                var parser = new less.Parser({});
                parser.parse(styleString, function (error, root) {
                    var cssCode = root.toCSS();

                    // change style
                    var myStyleTag = document.getElementById("less-edit-container");

                    if (!myStyleTag) {
                        // add tag to header
                        var headTag = document.getElementsByTagName("head")[0];
                        var styleNode = document.createElement('style');
                        styleNode.setAttribute("type", "text/css");
                        styleNode.setAttribute("id", "less-edit-container");
                        headTag.appendChild(styleNode);
                        myStyleTag = styleNode;
                    }


                    myStyleTag.innerHTML = '';
                    var textNode = document.createTextNode(cssCode);
                    myStyleTag.appendChild(textNode);

                });


            }
        }
    });



	
	
} catch (exc) {
	alert(exc);
}